package com.woniuxy.stage3demo.service.hpxservice.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.stage3demo.bean.hpxbean.OrderBean;
import com.woniuxy.stage3demo.mapper.hpxmapper.OrderMapper;
import com.woniuxy.stage3demo.pageHelper.PageRequest;
import com.woniuxy.stage3demo.service.hpxservice.IOrderService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Transactional(readOnly = true)
@Service
public class OrderServiceImpl implements IOrderService {

    @Resource
    private OrderMapper orderMapper;


    //关闭未付款项
    @Override
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    public int closeAllwfk() {
        return orderMapper.closeAllwfk();
    }

    //删除关闭项
    @Override
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    public int deleteAllgb() {
        return orderMapper.deleteAllgb();
    }

    //分页查询
    @Override
    public PageInfo<OrderBean> findAllByParams(PageRequest request, OrderBean orderBean) {
        return PageHelper.startPage(request.getPageNum(),request.getLimit())
                .doSelectPageInfo(()->orderMapper.findAllByParams(request,orderBean));
    }


}
